<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,height=device-height,viewport-fit=cover,initial-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">
	<meta name="format-detection" content="telephone=no,email=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="description" content="还卡超人">
	<meta name="keywords" content="还卡超人,拍拍贷">
	<title>开通存管账户</title>
	<style>
		body {
			margin: 1em 5%;
			background-color: #ffffff;
		}
		.result {
			display: none;
			margin-top: 60px;
		}
		img {
			display: block;
			width: 130px;
			margin: 0 auto;
		}
		p {
			margin: 16px 0;
			color: #252525;
			text-align: center;
			font-size: 15px;
		}
	</style>
</head>
<body>
	<div id="success" class="result">
		<img src="//hh.ppdaicdn.com/static/images/other_static/deposit_manage/success@2x.png"
		     srcset="//hh.ppdaicdn.com/static/images/other_static/deposit_manage/success@2x.png 2x, //hh.ppdaicdn.com/static/images/other_static/deposit_manage/success@3x.png 3x"
		     alt="result">
		<p>恭喜您，存管账户开通成功</p>
	</div>
	<div id="fail" class="result">
		<img src="//hh.ppdaicdn.com/static/images/other_static/deposit_manage/failure@2x.png"
		     srcset="//hh.ppdaicdn.com/static/images/other_static/deposit_manage/failure@2x.png 2x, //hh.ppdaicdn.com/static/images/other_static/deposit_manage/failure@3x.png 3x"
		     alt="result">
		<p>存管账户开通失败，请稍后再试</p>
	</div>
	<script>
		var GetQueryString = function (name) {
			var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
			var r = window.location.search.substr(1).match(reg);
			return r ? r[2] : null;
		};
		var isiOS = navigator.userAgent.match('iPad')
				|| navigator.userAgent.match('iPhone')
				|| navigator.userAgent.match('iPod');
		var evt = new Event('WebViewJavascriptBridgeReady');
		document.addEventListener('WebViewJavascriptBridgeReady', function () {
			var status = Math.min((GetQueryString('status') || 3), 3);
			userDepositManagementEnd(status);
			document.querySelector(['#success', '#fail', '#fail'][status - 1]).style.display = 'block';
		});
		if (isiOS) {
			var injectWebViewJavascriptBridge = function (callback) {
				if (window.WebViewJavascriptBridge) {
					return callback(WebViewJavascriptBridge);
				}
				if (window.WVJBCallbacks) {
					return window.WVJBCallbacks.push(callback);
				}
				window.WVJBCallbacks = [callback];
				var WVJBIframe = document.createElement('iframe');
				WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
				WVJBIframe.style.display = 'none';
				document.body.appendChild(WVJBIframe);
				setTimeout(function () {
					document.body.removeChild(WVJBIframe);
				}, 0);
			};
			var injectWebViewJavascriptBridgeCallback = function (bridge) {
				document.dispatchEvent(evt);
			};
			injectWebViewJavascriptBridge(injectWebViewJavascriptBridgeCallback);
		}
		var userDepositManagementEnd = function (status) {
			try {
				WebViewJavascriptBridge.callHandler('userDepositManagementEnd', {
					'code': 1,
					'name': '存管开户后续流程',
					'data': {
						'resultCode': status,
						'resultMessage': ['成功', '失败', '异常'][status - 1]
					}
				});
			} catch(ex) {
				try {
					AppBridge.userDepositManagementEnd(JSON.stringify({
						'resultCode': status,
						'resultMessage': ['成功', '失败', '异常'][status - 1]
					}));
				} catch (ex) {
					console.log('后续流程失败，请重试');
				}
			}
		};
	</script>
</body>
</html>
